home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Snippets
/
DirectoryPopup 1.0
/
□□□DPSample Source
/
SimpleAppAEHandlers.c
< prev
next >
Wrap
Text File
|
1996-06-03
|
2KB
|
105 lines
/*
* Project: SimpleApp
*
* Filename: SimpleAppAEHandlers.c
*
* Author: Marco Piovanelli
*
* Revision History:
*
* 1996.05.24 MP created this file
*
*/
#include "SimpleApp.h"
#include "Utilities.h"
OSErr GotRequiredParams ( const AppleEvent * ae )
{
DescType returnedType ;
Size actualSize ;
OSErr err = noErr ;
err = AEGetAttributePtr ( ae, keyMissedKeywordAttr, typeWildCard, & returnedType, nil, 0, & actualSize ) ;
if ( err == errAEDescNotFound )
return noErr ;
else if ( err == noErr )
return errAEParamMissed ;
else
return err ;
}
pascal OSErr HandleOpenDoc ( const AppleEvent * ae, AppleEvent * reply, SInt32 refCon )
{
#pragma unused ( reply, refCon )
AEDesc docList ;
OSErr err = noErr ;
InitDesc ( & docList ) ;
// extract direct parameter from event (must be a list of aliases)
if ( ( err = AEGetParamDesc ( ae, keyDirectObject, typeAEList, & docList ) ) != noErr )
goto cleanup ;
if ( ( err = GotRequiredParams ( ae ) ) != noErr )
goto cleanup ;
// count the items in the list of aliases
SInt32 docCount ;
if ( ( err = AECountItems ( & docList, & docCount ) ) != noErr )
goto cleanup ;
// loop through each alias in the list
for ( SInt32 docIndex = 1 ; docIndex <= docCount ; docIndex ++ )
{
AEKeyword keyword ;
DescType returnedType ;
Size returnedSize ;
FSSpec fileSpec ;
// get nth item as a file system specification record
if ( ( err = AEGetNthPtr ( & docList, docIndex, typeFSS, & keyword, & returnedType, & fileSpec, sizeof ( fileSpec ), & returnedSize ) ) != noErr )
goto cleanup ;
// open the specified file
if ( ( err = CreateWindow ( & fileSpec ) ) != noErr )
goto cleanup ;
}
cleanup:
ForgetDesc ( & docList ) ;
return err ;
}
pascal OSErr HandleOpenApp ( const AppleEvent * ae, AppleEvent * reply, SInt32 refCon )
{
#pragma unused ( reply, refCon )
OSErr err = noErr ;
if ( ( err = GotRequiredParams ( ae ) ) != noErr )
return err ;
if ( ( err = CreateWindow ( nil ) ) != noErr )
return err ;
return noErr ;
}
pascal OSErr HandleQuit ( const AppleEvent * ae, AppleEvent * reply, SInt32 refCon )
{
#pragma unused ( reply, refCon )
OSErr err = noErr ;
if ( ( err = GotRequiredParams ( ae ) ) != noErr )
return err ;
gExiting = true ;
return noErr ;
}